const Sequelize = require('sequelize');
const seq = new Sequelize('vue-mall','root','tiger',{'host':'127.0.0.1','port':3306,'dialect':'mysql'});

var User = seq.define('user', {
  firstName: {
    type: Sequelize.STRING,
    field: 'first_name' // Will result in an attribute that is firstName when user facing but first_name in the database
  },
  lastName: {
    type: Sequelize.STRING
  }
}, {
  freezeTableName: true // Model 对应的表名将与model名相同
});

User.sync({force: false}).then(function () {
  // 已创建数据表
  return User.create({
    firstName: 'John',
    lastName: 'Hancock'
  });
}).then(function (resp) {
  console.log("resp:"+JSON.stringify(resp));
}).catch((e) => {
  console.log("error occured !"+e);

}).finally(()=>{
  process.exit(0);
});